<template>
	<view>
		<mescroll-body ref="mescrollRef" @up="upCallback" @down="downCallback">
			<uni-list>
				<uni-list-item v-for="(v,k) in list" :key="k" :title="v.cash_status==0?'申请中':(v.cash_status==1?'提现成功':'提现失败')" :note="v.created_at" :rightText="v.money" :rightTextStyle="v.cash_status==0?rightOption3:(v.cash_status==1?rightOption2:rightOption)"></uni-list-item>
			</uni-list>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], 
		data() {
			return {
				params:{
					page:1,
					per_page:10,
					is_type:0,
				},
				list:[],
				rightOption:"font-size:35rpx;color:red;",
				rightOption2:"font-size:35rpx;color:green;",
				rightOption3:"font-size:35rpx;color:orange;"
			};
		},
		onLoad(opt) {
			if(!this.$isEmpty(opt.is_type)){
				this.params.is_type = opt.is_type
			}
		},
		methods:{
			upCallback(page){
				this.params.page = page.num; 
				this.params.per_page = page.size; 
				
				this.$http(this.$api.cashes,this.params).then(res=>{
					if(res.code == 200){
						if(this.params.page == 1){
							this.list = [];
						}
						this.list = this.list.concat(res.data.data||res.data); 
						this.mescroll.endBySize(this.params.per_page, res.data.total); 
						if(res.data.total<8){
							this.mescroll.endUpScroll(false)
						}
						if(res.data.total==0){
							this.mescroll.showEmpty();
						}
					}
				})
			},
			downCallback(){
				this.mescroll.resetUpScroll();
			}
		}
	}
</script>

<style lang="scss">

</style>
